function ready(){
	//getTrendsList();
	getMethodName();
	//choser_method();
	//$(".chosen-select").chosen({width: "438px;",height:"37px;"});
}

/*function choser_method(plan){
	$.ajax({
		type : "GET",
		url : encodeURI("/MockPlatform/Method/getMethodName"),
		async: false,
		dataType:"json",
		success : function(root) {
			planversion=root.mouldNameList;
			$("#trends_method").empty();
			$(planversion).each(function(i,v){
				$("#trends_method").append("<option value='"+v+"'>"+v);
			});
			if(plan!=null){
				$("#trends_method").val(plan);
			}
			$("#trends_method").trigger("chosen:updated");
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			alert("加载失败，请稍后再试");
		}
	});
}

function getTrendsList(){
	var url = "/MockPlatform/Trends/getTrendsList";
	
	$("#trends_List").html("");
	$.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			
			tmp = root;
			$(root.trendsNameList).each(
				function(i, value){
					
					$("#trends_List").append(
							"<li><a ><strong style=\"cursor:pointer;\" onclick=\"getTrends('"+value+"')\">"+value+"</strong>" +
							"<i class=\"icon-remove\" onclick=\"delTrends('"+value+"')\" style=\"float: right;cursor:pointer;\">" +
							"</i></a></li>"
					);
				});
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("查询失败，请稍后再试");
		}
	});
}

function getTrends(plan){
	var name = plan;
	var url = "/MockPlatform/Trends/getTrends?name="+name;
	
	$.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			
			tmp = root;
			$(root.trendsList).each(
				function(i, value){
					document.getElementById("trends_id").value = value.id;
					document.getElementById("trends_name").value =value.name;
					document.getElementById("trends_method").value =value.value;
					document.getElementById("trends_drscription").value =value.description;
					choser_method(value.name);
				});
			
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("查询失败，请稍后再试");
		}
	});
}

function clean(){
	document.getElementById("trends_id").value ="";
	document.getElementById("trends_name").value ="";
	document.getElementById("trends_method").value ="";
	document.getElementById("trends_drscription").value ="";
}

function insertTrends(){
	var name =document.getElementById("trends_name").value;
	var value =document.getElementById("trends_method").value;
	var description =document.getElementById("trends_drscription").value;
	var url = "/MockPlatform/Trends/insertTrends?name="+name+"&description="+description+"&value="+value;
	
	if(name!=""&&value!=""&&description!=""){
		$.ajax({
			type: "GET",
			url : encodeURI(url),
			dataType: "json",
			success: function (root) {
					if(root.success=="false"){
						justTip(root.name);
					}else{
						alert("添加成功！")
						getTrendsList();
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#queryButton").attr("value", "查询").removeAttr("disabled");
					alert("添加失败，请稍后再试");
				}
			});
	}else{
		alert("插入失败，请检查你输入的信息是否有误！")
	}
}


function updateTrends(){
	var id = document.getElementById("trends_id").value;
	var name =document.getElementById("trends_name").value;
	var value =document.getElementById("trends_method").value;
	var description =document.getElementById("trends_drscription").value;
	
	var url = "/MockPlatform/Trends/updateTrends?id="+id+"&name="+name+"&description="+description+"&value="+value;
		
		if(id!=""&&name!=""&&value!=""&&description!=""){
			$.ajax({
				type: "GET",
				url : encodeURI(url),
				dataType: "json",
				success: function (root) {
						if(root.success=="false"){
							justTip(root.name);
						}else{
							alert("修改成功！")
							getTrendsList();
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						$("#queryButton").attr("value", "查询").removeAttr("disabled");
						alert("修改失败，请稍后再试");
					}
				});
		}else{
			alert("修改失败，请检查你输入的信息是否有误！")
		}
}


function delTrends(plan){
	
	if(plan!=null){
		var name =plan;
	}
	
	var url = "/MockPlatform/Trends/delTrends?name="+name;
		
		if(name!=""){
			$.ajax({
				type: "GET",
				url : encodeURI(url),
				dataType: "json",
				success: function (root) {
						if(root.success=="false"){
							justTip(root.name);
						}else{
							alert("删除成功！")
							getTrendsList();
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						$("#queryButton").attr("value", "查询").removeAttr("disabled");
						alert("删除失败，请稍后再试");
					}
				});
		}else{
			alert("删除失败,请检查你需要删除的信息！")
		}
}
*/


function clean2(){
	document.getElementById("method_id").value = "";
	document.getElementById("method_name").value ="";
	document.getElementById("method_drscription").value ="";
}

function getMethodName(){
var url = "/MockPlatform/Scoket/linux";
	
	$("#method_List").html("");
	$.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			
			tmp = root;
			$(root.jarList).each(
				function(i, value){
					
					$("#method_List").append(
							"<li><a ><strong style=\"cursor:pointer;\" onclick=\"getMethodDescription('"+value+"')\">"+value+"</strong>" +
							"</a></li>"
					);
				});
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("查询失败，请稍后再试");
		}
	});
}


function getMethodDescription(plan){
	var jarName = plan;
	var url = "/MockPlatform/Scoket/describe?jarName="+jarName;
	
	$.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			
			tmp = root;
			document.getElementById("method_drscription").value =root.jarDescribe;
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("查询失败，请稍后再试");
		}
	});
}

/*function insertMethod(){
   var methodName =	document.getElementById("method_name").value;
   var description =	document.getElementById("method_drscription").value;
   
   var url =  "/MockPlatform/Method/insertMethod?methodName="+methodName+"&description="+description;
   
   if(methodName!=""&&description!=""){
   $.ajax({
		type : "GET",
		url : encodeURI(url),
		dataType : "json",
		success : function(root) {
			if(root.success=="false"){
				justTip(root.name);
			}else{
				alert("添加成功！")
				getMethodName();
				getMethodDescription(methodName);
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			$("#queryButton").attr("value", "查询").removeAttr("disabled");
			alert("添加失败，请稍后再试");
		}
	});
   }else{
	   alert("插入失败，请检查你输入的信息是否有误！")
   }
}


function updateMethod(){
	var id =	document.getElementById("method_id").value;
	var methodName =	document.getElementById("method_name").value;
	var description =	document.getElementById("method_drscription").value;
	
	var url = "/MockPlatform/Method/updateMethod?id="+id+"&methodName="+methodName+"&description="+description;
	
	if(id!=""&&methodName!=""&&description!=""){
		$.ajax({
			type : "GET",
			url : encodeURI(url),
			dataType : "json",
			success : function(root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					alert("修改成功！")
					getMethodName();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("修改失败，请稍后再试");
			}
		});
	}else{
		alert("修改失败，请检查你输入的信息是否有误！")
	}
}


function delMethod(plan){
	
	var methodName= plan;
	var url = "/MockPlatform/Method/delMethod?methodName="+methodName;
	
	if(methodName!=""){
		$.ajax({
			type : "GET",
			url : encodeURI(url),
			dataType : "json",
			success : function(root) {
				if(root.success=="false"){
					justTip(root.name);
				}else{
					alert("删除成功！")
					getMethodName();
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				$("#queryButton").attr("value", "查询").removeAttr("disabled");
				alert("删除失败，请稍后再试");
			}
		});
	}else{
		alert("删除失败，请检查你输入的信息是否有误！")
	}
}*/
